package com.xzm.MQ.direct;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.xzm.MQ.utils.RabbitMQUtils;

import java.io.IOException;

public class Provider {
    public static void main(String[] args) throws IOException {
        Connection connection = RabbitMQUtils.getConnection();
        Channel channel = connection.createChannel();
        //定义交换器，参数1是交换器名称，参数2是交换器种类，路由模式
        channel.exchangeDeclare("logs_direct","direct");
        //发送消息
        String routekey="error";
        //参数1为交换器名称，参数2为路由键
        channel.basicPublish("logs_direct",routekey,null,"这是发送的消息".getBytes());
        RabbitMQUtils.closeChannelAndConnetion(channel,connection);
    }
}
